﻿//namespace EasyWeb.Web.Controllers
//{
//    using System;
//    using System.Collections.Generic;
//    using System.Linq;
//    using System.Text;
//    using System.Threading.Tasks;
//    using System.Web.Mvc;

//    [EWHandleError]
//    public class EWSelectionItemController : Controller
//    {
//        public ActionResult Create(Guid ownerId)
//        {
//            return View(EWHelpers.Web.View.GetFullViewName());
//        }

//        [HttpPost]
//        public ActionResult Create(Guid ownerId, [Bind(Prefix = EWHelpers.Web.HtmlFieldPrefix)] EWSelectionItemDefinition model)
//        {
//            if (ModelState.IsValid)
//            {
//                using (var ts = EWHelpers.Data.BeginTransaction())
//                {
//                    EWHelpers.Data.DaoFactory.SelectionItemDefinitionDao.Create(ownerId, model);
//                    ts.Complete();
//                }

//                return RedirectToRoute("EasyWeb_Selection", new { action = "Details", id = ownerId });
//            }

//            return View(EWHelpers.Web.View.GetFullViewName(), model);
//        }

//        public ActionResult Details(Guid ownerId, Guid id)
//        {
//            EWSelectionItemDefinition model = null;

//            using (var ts = EWHelpers.Data.BeginTransaction())
//            {
//                model = EWHelpers.Data.DaoFactory.SelectionItemDefinitionDao.Select(id);
//                ts.Complete();
//            }

//            return View(EWHelpers.Web.View.GetFullViewName(), model);
//        }

//        [HttpPost]
//        public ActionResult Edit(Guid ownerId, [Bind(Prefix = EWHelpers.Web.HtmlFieldPrefix)] EWSelectionItemDefinition model)
//        {
//            if (ModelState.IsValid)
//            {
//                using (var ts = EWHelpers.Data.BeginTransaction())
//                {
//                    EWHelpers.Data.DaoFactory.SelectionItemDefinitionDao.Update(model);
//                    ts.Complete();
//                }

//                return RedirectToRoute("EasyWeb_Selection", new { action = "Details", id = ownerId });
//            }

//            return View(EWHelpers.Web.View.GetFullViewName("Details"), model);
//        }

//        [HttpPost]
//        public ActionResult Delete(Guid ownerId, [Bind(Prefix = EWHelpers.Web.HtmlFieldPrefix)] EWEntityDefinition model)
//        {
//            using (var ts = EWHelpers.Data.BeginTransaction())
//            {
//                EWHelpers.Data.DaoFactory.SelectionItemDefinitionDao.Delete(model.Id, model.Timestamp);
//                ts.Complete();
//            }

//            return RedirectToRoute("EasyWeb_Selection", new { action = "Details", id = ownerId });
//        }
//    }
//}
